
$(function(){
    var cols = [
        {title:'主键', name:'id', align: 'center',hidden:true},
        {title:'任务名称', name:'logTaskname', align: 'center'},
        {title:'执行时间', name:'logExectime', align: 'center',
            renderer:function(val,item,rowIndex){
                var d = new Date();
                d.setTime(val);
                return ""+d.getFullYear()+"-"+ (d.getMonth()+1)+"-"+ d.getDate()+" "+ d.getHours()+":"+ d.getMinutes()+":"+ d.getSeconds();
            }},
        {title:'执行方式', name:'logExectype', align: 'center',
            renderer:function(val,item,rowIndex){
                if(val=='1'){
                    return '自动';
                }else{
                    return '手动';
                }
            }},
        { title:'执行结果', name:'logExecresult' , align:'center',
            renderer:function(val,item,rowIndex){
                if(val=='1'){
                    return '成功';
                }else{
                    return '失败';
                }
            }},
        { title:'执行信息', name:'logExecmsg' , align:'center',width:300 }
    ];
    var grid=$('#datagrid').mmGrid({
        cols: cols,
        url: 'queryQuartzLogList.do',
        method: 'get',
        checkCol:true,
        plugins:[
            $('#paginator').mmPaginator({
                style: 'plain',
                totalCountName: 'totalCount',
                page: 1,
                pageParamName: 'pageNo',
                limitParamName: 'pageSize',
                limitLabel: '每页{0}条',
                totalCountLabel: '共<span>{0}</span>条记录',
                limit: undefined,
                limitList: [10,20, 30, 50]
            })
        ],
        showBackboard:false,
        fullWidthRows:true,
        checkCol:false,
        height:'auto',
        noDataText:'没有数据。',
        multiSelect:true
    });
    function refreshCondition(){
        var obj = new Object();
        if( $.trim( $('#logTaskname').val() ) != '' ){
            obj.logTaskname = $('#logTaskname').val();
        } else{
            delete grid.opts.params.logTaskname;
        }

        if( $.trim( $('#logExectime_begin').val() ) != '' ){
            obj.logExectime_begin = $('#logExectime_begin').val();
        } else{
            delete grid.opts.params.logExectime_begin;
        }

        if( $.trim( $('#logExectime_end').val() ) != '' ){
            obj.logExectime_end = $('#logExectime_end').val();
        } else{
            delete grid.opts.params.logExectime_end;
        }

        if( $.trim( $('#logExectype').val() ) != '' ){
            obj.logExectype = $('#logExectype').val();
        } else{
            delete grid.opts.params.logExectype;
        }

        if( $.trim( $('#logExecresult').val() ) != '' ){
            obj.logExecresult = $('#logExecresult').val();
        } else{
            delete grid.opts.params.logExecresult;
        }

        $.extend(grid.opts.params,obj);
    }
    $('#empty_link').click(function(){
        $('#logTaskname').val('');
        $('#logExectime_begin').val('');
        $('#logExectime_end').val('');
        $('#logExectype').val('');
        $('#logExecresult').val('');
    });

    $('#query_link').click(function(){
        refreshCondition();
        grid.resetLoad();
    });


})
